import { ElMessage, ElMessageBox } from 'element-plus'
import type { MessageType } from '@/types/types'

type Options = {
  confirmButtonText?: string,
  cancelButtonText?: string,
  type?: 'warning' | 'error'
}

export function openMessage(type: MessageType, message: string) {
  ElMessage({
    type,
    message,
    duration: 3000
  })
} 

export function openConfirmMessageBox(message: string, title: string, options?: Options) {
  return ElMessageBox.confirm(message, title,  {
    confirmButtonText: options?.confirmButtonText || '确定',
    cancelButtonText: options?.cancelButtonText || '取消',
    type: options?.type || 'warning',
  })
}